package com.chendx.store.order.controller;

import com.chendx.model.common.dtos.ResponseResult;
import com.chendx.model.order.dto.OrderDto;
import com.chendx.store.api.order.OrderControllerApi;
import com.chendx.store.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by chendx on 2022/4/20.
 */
@RestController
@RequestMapping("/api/order")
public class OrderController implements OrderControllerApi{

    @Autowired
    private OrderService orderService;


    @Override
    @PostMapping("/list")
    public ResponseResult loadOrderPage(@RequestBody OrderDto dto) {
        return orderService.loadOrderPage(dto);
    }

    @Override
    @GetMapping("/userall")
    public ResponseResult loadUserAllOrder() {
        return orderService.loadUserAllOrder();
    }

    @Override
    @PostMapping("/addCartOrder")
    public ResponseResult addCartOrder(@RequestBody OrderDto dto) {
        return orderService.addCartOrder(dto);
    }

    @Override
    @GetMapping("/prePrice")
    public ResponseResult afterPrePrice(String prefId) {
        return orderService.afterPrePrice(prefId);
    }

    @Override
    @PostMapping("/addOrder")
    public ResponseResult addOrder(@RequestBody OrderDto dto) {
        return orderService.addOrder(dto);
    }

    @Override
    @GetMapping("/one")
    public ResponseResult one(String id) {
        return orderService.loadOne(id);
    }

    @Override
    @PostMapping("/pay")
    public ResponseResult pay(@RequestBody OrderDto dto) {
        return orderService.pay(dto);
    }

    @Override
    @GetMapping("/close")
    public ResponseResult close(String id) {
        return orderService.closeOrder(id);
    }

    @Override
    @GetMapping("/delete")
    public ResponseResult delete(String id) {
        return orderService.deleteOrder(id);
    }

    @Override
    @GetMapping("/cancel")
    public ResponseResult cancelOrder(String id) {
        return orderService.cancelOrder(id);
    }

    @Override
    @GetMapping("/goods")
    public ResponseResult goodsOrder(String id) {
        return orderService.goods(id);
    }

}
